﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class FinanceCenter_PVList : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //tbStartTime.Attributes.Add("onclick", "WdatePicker()");
            //tbEndTime.Attributes.Add("onclick", "WdatePicker()");

            //DateTime dtime = DateTime.Now;
            //tbStartTime.Value = DateTime.Parse(dtime.Year.ToString() + "-" + dtime.Month + "-01 00:00:00").ToString("yyyy-MM-dd");
            //tbEndTime.Value = dtime.ToString("yyyy-MM-dd");

            BindData();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        isAtFramePageLogin = true;                              //是框架页
        RequestLoginPage = this.Request.Url.AbsoluteUri;
        RequestCompetences = Competences.BuildCompetencesList(Competences.Finance);

        base.OnInit(e);
    }

    #endregion

    private void BindData()
    {
        //DateTime StartTime = Shove._Convert.StrToDateTime(tbStartTime.Value.ToString(), DateTime.Now.ToShortDateString());
        //DateTime EndTime = Shove._Convert.StrToDateTime(tbEndTime.Value.ToString(), DateTime.Now.ToShortDateString());

        DataTable dt = null;

        dt = new DAL.Views.V_Earning().Open("", "datediff(mm,DateTime,getdate())=0", "");

        if (dt != null && dt.Rows.Count > 0)
        {
            g.DataSource = dt;
            g.DataBind();

            gPager.Visible = dt.Rows.Count > 0;
        }        
    }

    protected void ibSelect_Click(object sender, ImageClickEventArgs e)
    {
        gPager.PageIndex = 0;

        BindData();
    }

    protected void g_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
        {
            
        }
    }

    protected void gPager_PageWillChange(object Sender, Shove.Web.UI.PageChangeEventArgs e)
    {
        BindData();
    }

    protected void gPager_SortBefore(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
    {
        BindData();
    }


    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (DAL.Procedures.P_PVList() >= 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "统计成功!");
        }
        else
        {
            Shove._Web.JavaScript.Alert(this.Page, "统计失败!");
        }
    }
}

